package com.atguigu.study.cas;

import java.util.concurrent.atomic.AtomicInteger;

public class CasHello {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);//内存位置  ,expectedValue 预期值, newValue 更新值
        System.out.println(atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5,2025)+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5,1111)+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.incrementAndGet()+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.getAndIncrement()+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.addAndGet(3));
    }
}
